<layout name="page" />
<block name="content">
	{:widget('page_header/simple',array('name'=>'会议室管理'))}
	<div class="operate-panel">
		<a onclick="go_index()" class="btn">返回</a>
		<div class="split"></div>
		<a onclick="add()" class="btn">新增</a>
		<a id="btn_save" class="btn">保存</a>
		<a onclick="del()"class="btn btn-del">删除</a>
	</div>
	<div class="row">
		<div class="sub-sidebar">
			<table class="table table-bordered">
				<thead>
					<tr>
						<th>名称</th>
						<th>状态</th>
					</tr>
				</thead>
				<tbody>
					<volist name="list" id="data">
						<tr id="{$data.id}">
							<td>{$data.name}</td>
							<td>{$data.is_del|status}</td>
						</tr>
					</foreach>
				</tbody>
			</table>
			<div class="pagination">
				{$page}
			</div>
		</div>

		<div class="input-block sub-content">
			<form id="form_data" name="form_data"method="post" >
				<input type="hidden" name="id" id="id">
				<input type="hidden" name="ajax" id="ajax" value="0">
				<input type="hidden" name="opmode" id="opmode" value="">

				
					<label class="input-label" for="name">会议室名称*：</label>
					
						<input class="input"  type="text" id="name" name="name" check="required" info="请输入名称">
					</div>
				</div>

				
					<label class="input-label" for="sort">会议室顺序：</label>
					
						<input class="input"  type="text" id="sort" name="sort" >
					</div>
				</div>
				
					<label class="input-label" for="num">可容纳人数：</label>
					
						<input class="input"  type="text" id="num" name="num" >
					</div>
				</div>
				
					<label class="input-label" for="addr">会议室地址：</label>
					
						<input class="input"  type="text" id="addr" name="addr" >
					</div>
				</div>
				
					<label class="input-label" for="media">是否有多媒体：</label>
					
						<select  class="input" name="media" id="media">
							<option  value="0">没有</option>
							<option value="1">有</option>
						</select>
					</div>
				</div>
				
					<label class="input-label" for="projector">是否有投影仪：</label>
					
						<select  class="input" name="projector" id="projector">
							<option  value="0">没有</option>
							<option value="1">有</option>
						</select>
					</div>
				</div>

				
					<label class="input-label" for="is_del">状态：</label>
					
						<select  class="input" name="is_del" id="is_del">
							<option  value="0">启用</option>
							<option value="1">禁用</option>
						</select>
					</div>
				</div>

			</form>
		</div>
	</div>
</block>
<block name="js">
	<script type="text/javascript">
		layui.use('global', function() {
			var $ = layui.jquery;
			$(document).ready(function() {
				set_return_url(null);
				$(".sub-sidebar tbody tr").click(function() {
					$(".sub-sidebar  tr.active").removeClass("active");
					$(this).attr("class", "active");
					send_ajax("{:url('readroom')}", "id=" + $(this).attr("id"), function(data) {
						show_data(data);
					});
					return false;
				});
			});
		});
		function add() {
			winopen("{:url('addroom')}", 560, 470);
		};

		$("#btn_del").on('click', function() {
			var vars = $("#form_data").serialize();
			layui.msg('确定要删除吗?', function() {
				send_ajax("{:url('delroom')}", vars, function(data) {
					if (data.status) {
						layer.msg(data.info, function() {
							location.reload(true);
						});
					}
				});
			});
		});

		function save() {
			send_form("form_data", "{:url('saveroom')}");
		}

		function go_index() {
			window.open("{:url('index')}", "_self");
		}

		function show_data(result) {

			for (var s in result.data) {
				set_val(s, result.data[s]);
			}
			$("#opmode").val("edit");
		}

	</script>

</block>